var app = getApp()
var util = require('../../utils/util.js');
Page({
  data: {
    // 导航按钮    
    currentTab: 0,
    imgsrc:'',
    mohuanUser:'',
    userInfo:''
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数

  },
  onShow:function(){
    var that = this
    that.setData({
      userInfo: app.globalData.userInfo,
      mohuanUser: app.globalData.mohuanUser
    })
    util.getQrcodeImg(`/c2mwebservice/api/v2/customization/getQrcode/` + that.data.mohuanUser.memberId, function (res) {      
      if (res.returnCode == '200') {     
         that.setData({
           imgsrc: res.returnData.qrCode
         })    
      }
    }, function (error) {
      console.log(error)
      wx.hideToast()
    })

  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    that.setData({
      currentTba: e.detail.current
    });
  },

  // 点击图片保存分享
  previewImage:function(e){
    var current = e.target.dataset.src;
    // console.log(current)
    wx.previewImage({
      urls: current.split(',')
      // 需要预览的图片http链接  使用split把字符串转数组。不然会报错
    })

  },
  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  }

})
